/**********************************************************************
* <pre>
* FILE : DlrInfoMng.java
* CLASS : DlrInfoMng
*
* AUTHOR : LAX
*
* FUNCTION : 经销商信息维护.
*
*
*======================================================================
* CHANGE HISTORY LOG
*----------------------------------------------------------------------
* MOD. NO.| DATE     | NAME | REASON | CHANGE REQ.
*----------------------------------------------------------------------
*         |2009-08-18| LAX  | Created |
* DESCRIPTION:
* </pre>
***********************************************************************/
/**
 * $Id: DlrInfoMng.java,v 1.6 2010/12/01 03:51:49 yangz Exp $
 */
package com.infodms.dms.actions.sysmng.orgmng;

import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;

import org.apache.log4j.Logger;

import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.bean.CompanyBean;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.common.MsgCarrier;
import com.infodms.dms.common.ValidateCodeConstant;
import com.infodms.dms.dao.orgmng.CompanyInfoDAO;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.TmBrandPO;
import com.infodms.dms.po.TmCompanyPO;
import com.infodms.dms.po.TmOrgPO;
import com.infodms.dms.util.CommonUtils;
import com.infodms.dms.util.businessUtil.Validate;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.po3.POFactory;
import com.infoservice.po3.POFactoryBuilder;
import com.infoservice.po3.bean.PageResult;

/**
 * Function       :  经销商信息维护
 * @author        :  LAX
 * CreateDate     :  2009-08-18
 * @version       :  0.1
 */
public class DlrInfoMng {
	private Logger logger = Logger.getLogger(DlrInfoMng.class);
	private POFactory factory = POFactoryBuilder.getInstance();
	private ActionContext act = ActionContext.getContext();
	private AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
	
	/**
	 * Function       :  根据条件查询系统中经销商明细信息 
	 * @param         :  request-经销商ID
	 * @return        :  经销商明细
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-18
	 */
	public void querySingleDlrInfo() throws Exception {
		Long dealerId = null;          //经销商ID
		String flag = "";
		try {
			RequestWrapper request = act.getRequest();
			if(request.getParamValue("dlrId") == null){
				dealerId = logonUser.getCompanyId();
			}else{
				flag = "1";
				dealerId = new Long(request.getParamValue("dlrId"));
			}
			
			//得到认证品牌
			List<TmBrandPO> sgmlist = CompanyInfoDAO.getSGMBrand();
//			//得到经销商对应的SGM认证品牌
//			List<TrDlrBrandPO> dlrsgmlist = DlrInfoDAO.getDlrSGMBrand(dealerId);
			//得到经销商明细信息
			CompanyBean bean = new CompanyBean();
			List<CompanyBean> companyList = CompanyInfoDAO.getCompanyInfoItem(dealerId);
			bean = companyList.get(0);
			
			act.setOutData("flag", flag);
			act.setOutData("SGM_LIST", sgmlist);
//			act.setOutData("DLR_SGM_LIST", dlrsgmlist);
			act.setOutData("DEALER_BEAN", bean);
			
			act.setForword("/jsp/systemMng/orgMng/dealerInfoDetail.jsp");
		}catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);
		}catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"经销商明细信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	
	/**
	 * Function       :  经销商信息维护－根据条件查询系统中所有经销商信息 
	 * @param         :  request-经销商代码、经销商名称、公司类型、所属部门ID、排序字段名、排序参数
	 * @return        :  系统中经销商明细
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-18
	 */
	public void queryAllDlrInfo() throws Exception {
		String companyCode = null;        //公司代码
		String companyName = null;        //公司名称
		String companyType = null;       //公司类型
		String oemCompanyId=null;        //公司ID

		try {
			RequestWrapper request = act.getRequest();
			if("1".equals(request.getParamValue("command"))){ //json请求
				/**
				* 得到页面参数
				*/
				companyCode = CommonUtils.checkNull(request.getParamValue("COMPANY_CODE"));	
				companyName = CommonUtils.checkNull(request.getParamValue("COMPANY_NAME"));
				//companyType = request.getParamValue("COMPANY_TYPE");
				//这里写死为经销商公司
				companyType=Constant.COMPANY_TYPE_DEALER;
				// 后台验证经销商代码、经销商名称
				oemCompanyId=logonUser.getCompanyId().toString();
				List<MsgCarrier> list = new ArrayList<MsgCarrier>();
				list.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_PATTERN,"公司代码",0,Constant.Length_Check_Char_10,companyCode));
				list.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"公司名称",0,Constant.Length_Check_Char_30,companyName));
				Validate.doValidate(act, list);
				//获取排序字段和排序类型
				String orderName = request.getParamValue("orderCol");
				String da = request.getParamValue("order");
				
				Integer curPage = request.getParamValue("curPage") !=null ? Integer.parseInt(request.getParamValue("curPage")) : 1;
				//得到系统中所有经销商
				PageResult<CompanyBean> ps = CompanyInfoDAO.getAllCompanyInfo(oemCompanyId,companyCode, companyName, companyType, Constant.PAGE_SIZE, curPage,orderName,da);
				act.setOutData("ps", ps);
			}
			act.setForword("/jsp/systemMng/orgMng/dealerInfo.jsp");			
		}catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);
		}catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"经销商信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	
	/**
	 * Function       :  经销商信息查询－根据条件查询系统中所有经销商信息 
	 * @param         :  request-经销商代码、经销商名称、公司类型、所属部门ID、排序字段名、排序参数
	 * @return        :  系统中经销商明细
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-18
	 */
	public void dlrInfoSearch() throws Exception {
		String dealerCode = null;        //经销商代码
		String dealerName = null;        //经销商名称
		String companyType = null;       //公司类型
		String oemCompanyId=null;        //车厂公司ID
		
		PageResult<CompanyBean> ps = null;
		try {
			RequestWrapper request = act.getRequest();
			if("1".equals(request.getParamValue("command"))){ //json请求
				/**
				* 得到页面参数
				*/
				dealerCode = CommonUtils.checkNull(request.getParamValue("DLR_CODE"));	
				dealerName = CommonUtils.checkNull(request.getParamValue("DLR_NAME"));
				companyType = request.getParamValue("COMPANY_TYPE");
				if(logonUser.getOrgType().toString().equals(Constant.ORG_TYPE_OEM)){
					oemCompanyId=logonUser.getCompanyId().toString();
				}else{
					oemCompanyId=logonUser.getOemCompanyId();
				}
				
				// 后台验证经销商代码、经销商名称
				List<MsgCarrier> list = new ArrayList<MsgCarrier>();
				list.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_PATTERN,"经销商代码",0,Constant.Length_Check_Char_10,dealerCode));
				list.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"经销商名称",0,Constant.Length_Check_Char_30,dealerName));
				Validate.doValidate(act, list);
				//获取排序字段和排序类型
				String orderName = request.getParamValue("orderCol");
				String da = request.getParamValue("order");
					
				Integer curPage = request.getParamValue("curPage") !=null ? Integer.parseInt(request.getParamValue("curPage")) : 1;
				//得到系统中所有经销商
				ps = CompanyInfoDAO.getAllCompanyInfo(oemCompanyId,dealerCode, dealerName, companyType, Constant.PAGE_SIZE, curPage,orderName,da);
				act.setOutData("ps", ps);
			}
			act.setForword("/jsp/systemMng/orgMng/dealerInfoSearch.jsp");			
		}catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);
		}catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"经销商信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	
	/**
	 * Function       :  查询系统中SGM认证品牌 
	 * @param         :  request
	 * @return        :  SGM认证品牌
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-19
	 */
	public void queryDlrBrand() throws Exception {
		try {
			//得到SGM认证品牌
			//List<TmBrandPO> list = CompanyInfoDAO.getSGMBrand();
			List<TmBrandPO> list = null;
			act.setOutData("list", list);
			
			act.setForword("/jsp/systemMng/orgMng/companyInfoAdd.jsp");			
		/*}catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);*/
		}catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"SGM认证品牌信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	
	/**
	 * Function       :  新增经销商信息
	 * @param         :  request-经销商名称、经销商代码、所属部门ID、经销商简称、省份、城市、开业时间、SAP账号
	 * @param         :  request-公司类型、传真、负责人、电话、手机、地址、邮编、邮箱、状态、品牌ID
	 * @return        :  新增经销商成功或失败
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-19
	 */
	public void addCompanyInfo() throws Exception {
		String companyName = null;          //名称
		String companyCode = null;          //代码
		String companyShortname = null;  //简称
		String companyType = null;      //公司类型
		String fax = null;              //传真
		String phone = null;          //电话
		String address = null;         //地址
		String zipCode = null;          //邮编
		String status = null;          //状态
		String province = null;
		String city = null;
		String brandId = null;          //品牌ID
		String[] brandList = null;
		try {
			RequestWrapper request = act.getRequest();
			/**
			 * 得到页面参数
			 */
			companyName = CommonUtils.checkNull(request.getParamValue("DLR_NAME"));
			companyCode = CommonUtils.checkNull(request.getParamValue("DLR_CODE"));
			companyShortname = CommonUtils.checkNull(request.getParamValue("DLRNAMEFORSHORT"));
			fax = CommonUtils.checkNull(request.getParamValue("FAX"));
			phone = CommonUtils.checkNull(request.getParamValue("CONT_TEL"));
			address = CommonUtils.checkNull(request.getParamValue("DETL_ADDR"));
			zipCode = CommonUtils.checkNull(request.getParamValue("ZIP_CODE"));
			status = CommonUtils.checkNull(request.getParamValue("DLR_STAT"));
			companyType = CommonUtils.checkNull(request.getParamValue("COMPANY_TYPE"));
			province = CommonUtils.checkNull(request.getParamValue("PROVINCE"));
			city = CommonUtils.checkNull(request.getParamValue("CITY"));
			
//			 后台验证经销商代码、经销商名称、经销商简称、负责人、地址、邮编、邮箱
			List<MsgCarrier> msglist = new ArrayList<MsgCarrier>();
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_PATTERN,"经销商代码",0,Constant.Length_Check_Char_10,companyCode));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"经销商名称",0,Constant.Length_Check_Char_30,companyName));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"经销商简称",0,Constant.Length_Check_Char_15,companyShortname));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"地址",0,Constant.Length_Check_Char_30,address));
			//Validate.doValidate(act, msglist);
			//从SESSION中查询出oemCompanyId
			Long oemCompanyId=logonUser.getCompanyId();
			//获取排序字段和排序类型
			
			Enumeration enu = request.getParamNames();
			while(enu.hasMoreElements()){
				String brand = (String) enu.nextElement();
				if(brand.startsWith("BRAND")){
					brandList = request.getParamValues(brand);
				}
			}
			
			//判断新增的经销商信息是否已经存在相应的经销商表中
			List <TmCompanyPO> list = CompanyInfoDAO.getDlr(companyCode/*, companyName, companyShortname*/);//去掉经销商公司名称、简称重名判断
			long len = list.size() ;
			// 若将公司的状态修改为无效，则不用验证
			if(status.equals(Constant.STATUS_DISABLE.toString())) {
				len = 0 ;
			}
			String companyId=SequenceManager.getSequence("");
			if(len > 0){
				act.setOutData("ACTION_RESULT","2");
			}else{
				TmCompanyPO tmcompanyPO = new TmCompanyPO();
				if(companyId!=null&&companyId!=""){
				tmcompanyPO.setCompanyId(new Long(companyId));
				}
				tmcompanyPO.setCompanyName(companyName);
				tmcompanyPO.setCompanyCode(companyCode);
				tmcompanyPO.setCompanyShortname(companyShortname);
				tmcompanyPO.setFax(fax);
				tmcompanyPO.setPhone(phone);
				tmcompanyPO.setAddress(address);
				if(province!=null&&province!=""){
				tmcompanyPO.setProvinceId(new Long(province));
				}
				if(city!=null&&city!=""){
				tmcompanyPO.setCityId(new Long(city));
				}
				if(!"".equals(zipCode) && zipCode != null){
					tmcompanyPO.setZipCode(zipCode);
				}
				//tmcompanyPO.setCompanyType(Integer.valueOf(companyType));
				tmcompanyPO.setCompanyType(new Integer(Constant.COMPANY_TYPE_DEALER));//写死，目前功能只维护经销商公司
				tmcompanyPO.setStatus(Integer.valueOf(status));
				tmcompanyPO.setCreateBy(logonUser.getUserId());
				tmcompanyPO.setCreateDate(new Date(System.currentTimeMillis()));
				tmcompanyPO.setOemCompanyId(oemCompanyId);
				//将新增的经销商信息插入公司表
				factory.insert(tmcompanyPO);
				
					TmOrgPO tmorgPO = new TmOrgPO();
					String orgId=SequenceManager.getSequence("");
					if(orgId!=""&&orgId!=null){
					tmorgPO.setOrgId(new Long(orgId));
					}
					//tmorgPO.setParentOrgId(new Long(orgId));
					tmorgPO.setOrgCode(companyCode);
					tmorgPO.setOrgName(companyShortname);
					tmorgPO.setStatus(Integer.valueOf(Constant.STATUS_ENABLE));
					tmorgPO.setCreateBy(logonUser.getUserId());
					tmorgPO.setCreateDate(new Date(System.currentTimeMillis()));
					if(companyId!=null&&companyId!=""){
					tmorgPO.setCompanyId(new Long(companyId));
					}
					if(companyType.equals(Constant.COMPANY_TYPE_SGM))
					{
						tmorgPO.setOrgType(Integer.valueOf(Constant.ORG_TYPE_OEM));
						tmorgPO.setDutyType(Constant.DUTY_TYPE_COMPANY);
						
					}else
					{
						tmorgPO.setOrgType(Integer.valueOf(Constant.ORG_TYPE_DEALER));
						tmorgPO.setDutyType(Constant.DUTY_TYPE_DEALER);
					}
					//将新增的部门信息插入部门表
					factory.insert(tmorgPO);
				//判断是否选择了认证品牌
//				if(brandList != null){
//					for(int i = 0;i < brandList.length;i++){
//						brandId=brandList[i];
//						TrDlrBrandPO trdlrbrandPO = new TrDlrBrandPO();
//						trdlrbrandPO.setDlrBrandId(factory.getStringPK(trdlrbrandPO));
//						trdlrbrandPO.setDlrId(String.valueOf(tmcompanyPO.getCompanyId()));
//						trdlrbrandPO.setCreateBy(logonUser.getUserId());
//						trdlrbrandPO.setCreateDate(new Date(System.currentTimeMillis()));
//						trdlrbrandPO.setBrandId(brandId);
//						//将新增的经销商与其对应的SGM认证品牌插入经销商认证品牌表
//						factory.insert(trdlrbrandPO);
//					}
//				}
				
				act.setOutData("ACTION_RESULT","1");
			}
			
		}catch (Exception e) {
				BizException e1 = new BizException(act,e,ErrorCodeConstant.ADD_FAILURE_CODE,"经销商信息");
				logger.error(logonUser,e1);
				act.setException(e1);
		}
	}
	
	/**
	 * Function       :  根据公司ID查询其对应的信息
	 * @param         :  request-公司ID
	 * @return        :  公司信息
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-19
	 */
	public void getCompanyInfo(){
		Long companyId = null;          //公司ID
		try {
			RequestWrapper request = act.getRequest();
			/**
			 * 得到页面参数
			 */
			companyId = new Long(CommonUtils.checkNull(request.getParamValue("companyId")));
			
			//得到SGM认证品牌
			//List<TmBrandPO> sgmlist = CompanyInfoDAO.getSGMBrand();
			
			//得到公司信息
			CompanyBean companyBean = new CompanyBean();
			List<CompanyBean> companyList = CompanyInfoDAO.getCompanyInfoItem(companyId);
			companyBean = companyList.get(0);
			
			//act.setOutData("SGM_LIST", sgmlist);
			act.setOutData("COMPANY_BEAN", companyBean);
			
			act.setForword("/jsp/systemMng/orgMng/companyInfoMdf.jsp");
		}catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);
		}catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"SGM认证品牌信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	
	/**
	 * Function       :  更新公司信息
	 * @param         :  request-经销商ID、经销商名称、经销商代码、所属部门ID、经销商简称、省份、城市、开业时间、SAP账号
	 * @param         :  request-公司类型、传真、负责人、电话、手机、地址、邮编、邮箱、状态、品牌ID
	 * @return        :  更新经销商成功或失败
	 * @throws        :  Exception
	 * LastUpdate     :  2009-08-20
	 */
	public void updateCompanyInfo(){
		String companyId = null;            //经销商ID
		String companyName = null;          //经销商名称
		String companyCode = null;          //经销商代码
		String companyShortname = null;  //经销商简称
		String companyType = null;      //公司类型
		String fax = null;              //传真
		String phone = null;          //电话
		String address = null;         //地址
		String zipCode = null;          //邮编
		String status = null;          //状态
		String provinceId=null; //省份
		String cityId=null;     //城市
		try {
			RequestWrapper request = act.getRequest();
			/**
			 * 得到页面参数
			 */
			companyId = CommonUtils.checkNull(request.getParamValue("COMPANY_ID"));
			companyName = CommonUtils.checkNull(request.getParamValue("COMPANY_NAME"));
			companyCode = CommonUtils.checkNull(request.getParamValue("COMPANY_CODE"));
			companyShortname = CommonUtils.checkNull(request.getParamValue("COMPANY_SHORTNAME"));
			fax = CommonUtils.checkNull(request.getParamValue("FAX"));
			phone = CommonUtils.checkNull(request.getParamValue("PHONE"));
			address = CommonUtils.checkNull(request.getParamValue("ADDRESS"));
			zipCode = CommonUtils.checkNull(request.getParamValue("ZIP_CODE"));
			status = CommonUtils.checkNull(request.getParamValue("STATUS"));
			companyType = CommonUtils.checkNull(request.getParamValue("COMPANY_TYPE"));
			provinceId= CommonUtils.checkNull(request.getParamValue("PROVINCE_ID"));
			cityId= CommonUtils.checkNull(request.getParamValue("CITY_ID"));
			
//			 后台验证经销商代码、经销商名称、经销商简称、负责人、地址、电话、邮箱
			List<MsgCarrier> msglist = new ArrayList<MsgCarrier>();
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_PATTERN,"公司代码",0,Constant.Length_Check_Char_10,companyCode));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"公司名称",0,Constant.Length_Check_Char_30,companyName));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"公司简称",0,Constant.Length_Check_Char_15,companyShortname));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.DIGIT_LETTER_CN_PATTERN,"地址",0,Constant.Length_Check_Char_30,address));
			msglist.add(MsgCarrier.getInstance(ValidateCodeConstant.PHONE_PATTERN,"联系电话",0,Constant.Length_Check_Char_20,phone));
			//Validate.doValidate(act, msglist);
			//获取排序字段和排序类型
			
			
			
			//判断修改的经销商信息是否已经存在相应的经销商表中
			List <TmCompanyPO> list = CompanyInfoDAO.queryCompanyInfo(companyCode/*,companyName,companyShortname*/); //去掉经销商公司名称、简称重名判断
			long len = list.size() ;
			// 若将公司的状态修改为无效，则不用验证
			if(status.equals(Constant.STATUS_DISABLE.toString())) {
				len = 0 ;
			}
			if(len > 1){
				act.setOutData("ACTION_RESULT","2");
			}else{
				TmCompanyPO tmcompanyPO = new TmCompanyPO();
				tmcompanyPO.setCompanyName(companyName);
				tmcompanyPO.setCompanyCode(companyCode);
				tmcompanyPO.setCompanyShortname(companyShortname);
				tmcompanyPO.setFax(fax);
				tmcompanyPO.setPhone(phone);
				tmcompanyPO.setAddress(address);
				if(!"".equals(zipCode) && zipCode != null){
					tmcompanyPO.setZipCode(zipCode);
				}
				if(!"".equals(provinceId) && provinceId != null){
					tmcompanyPO.setProvinceId(new Long(provinceId));
				}
				if(!"".equals(cityId) && cityId != null){
					tmcompanyPO.setCityId(new Long(cityId));
				}
			
				tmcompanyPO.setCompanyType(Integer.valueOf(companyType));
				tmcompanyPO.setStatus(Integer.valueOf(status));
				tmcompanyPO.setUpdateBy(logonUser.getUserId());
				tmcompanyPO.setUpdateDate(new Date(System.currentTimeMillis()));
				TmCompanyPO tmcompanyPO1 = new TmCompanyPO();
				tmcompanyPO1.setCompanyId(new Long(companyId));
				//根据经销商ID在数据库中更新经销商信息
				factory.update(tmcompanyPO1, tmcompanyPO);
//				if(companyType.equals(Constant.COMPANY_TYPE_SGM))
//				{
//					//获取车厂公司ID对应的部门ID
//					TmOrgPO orgPO2 = new TmOrgPO();
//					List<TmOrgPO> orgList = CompanyInfoDAO.queryOrgId(companyId);
//					orgPO2 = orgList.get(0);
//					Long orgId = orgPO2.getOrgId();
//					
//					TmOrgPO deptPO1 = new TmOrgPO();
//					deptPO1.setOrgId(orgId);
//					TmOrgPO deptPO = new TmOrgPO();
//					deptPO.setOrgName(companyShortname);
//					deptPO.setUpdateBy(logonUser.getUserId());
//					deptPO.setUpdateDate(new Date(System.currentTimeMillis()));
//					//根据部门ID在数据库中更新部门信息 
//					factory.update(deptPO1, deptPO);
//				}
				
				
				//判断是否选择了认证品牌
//				if(brandList != null){
//					TrDlrBrandPO dlrbrandPO = new TrDlrBrandPO();
//					dlrbrandPO.setDlrId(dlrId);
//					factory.delete(dlrbrandPO);
//					for(int i = 0;i < brandList.length;i++){
//						brandId=brandList[i];
//						TrDlrBrandPO trdlrbrandPO = new TrDlrBrandPO();
//						trdlrbrandPO.setDlrBrandId(factory.getStringPK(trdlrbrandPO));
//						trdlrbrandPO.setDlrId(dlrId);
//						trdlrbrandPO.setCreateBy(logonUser.getUserId());
//						trdlrbrandPO.setCreateDate(new Date(System.currentTimeMillis()));
//						trdlrbrandPO.setBrandId(brandId);
//						//将经销商与其对应的SGM认证品牌插入经销商认证品牌表
//						factory.insert(trdlrbrandPO);
//					}
//				}else{
//					TrDlrBrandPO trdlrbrandPO1 = new TrDlrBrandPO();
//					trdlrbrandPO1.setDlrId(dlrId);
//					factory.delete(trdlrbrandPO1);
//				}		
				act.setOutData("ACTION_RESULT","1");
			}
			
		}catch (Exception e) {
			e.printStackTrace();
			BizException e1 = new BizException(act,e,ErrorCodeConstant.UPDATE_FAILURE_CODE,"公司信息");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}

}
